#include "Input.h"

using namespace std;

Input::Input(int _ln)
    : Stmt(_ln)
{
}


Input::~Input(void)
{
    for (auto iter = idList.begin(); iter != idList.end(); ++iter)
        delete *iter;
}

int Input::Eval()
{
    for (auto iter = idList.begin(); iter != idList.end(); ++iter)
    {
        Assignable *id = *iter;
        if (id->Type() == INT)
        {
            int value = -1;
            scanf("%d", &value);
            id->SetValue(value);
        }
        else if (id->Type() == FLT)
        {
            float value = -1;
            scanf("%f", &value);
            id->SetValue(value);
        }
    }    

    return -1;
}

void Input::AddVar( Assignable *var )
{
    idList.push_back(var);
}
